from django.db import models


# Create your models here.
class BookType(models.Model):
    name = models.CharField(max_length=20, verbose_name='图书类别')

    class Meta:
        db_table = '02_book_type'
        verbose_name_plural = '图书类别'
    def __str__(self):
        return self.name


class BookInfo(models.Model):
    name = models.CharField(max_length=20, verbose_name='图书名称')
    author = models.CharField(max_length=20, verbose_name='作者', default='未知作者')
    ISBN = models.CharField(max_length=20, verbose_name='ISBN编号', unique=True)
    book_type = models.ForeignKey(BookType, verbose_name='图书类别', on_delete=models.CASCADE, related_name="type_book")
    status = models.BooleanField(verbose_name='上架状态', default=True)
    disable = models.BooleanField(verbose_name='禁用状态', default=False)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='添加时间')

    class Meta:
        db_table = '02_book_info'
        verbose_name_plural = '图书信息'


class LoginAdmin(models.Model):
    username = models.CharField(max_length=20, verbose_name='用户名')
    password = models.CharField(max_length=20, verbose_name='密码')

    class Meta:
        db_table = '02_login_admin'
        verbose_name_plural = '登录信息'
